/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model.dao.ibatis;

import com.ibatis.sqlmap.client.SqlMapClient;
import model.dao.MocionDao;
import model.bean.Mocion;
import java.util.List;
import java.util.Map;
import model.common.ibatis.IbatisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

/**
 * @Archivo MocionDaoIbatis.java
 * @Fecha                @Autor   @Cambios
 * 10/02/2011 05:06:39 PM       moshiro
 */
@Repository
public class MocionDaoIbatis extends SqlMapClientDaoSupport implements MocionDao{

    @Autowired
    public MocionDaoIbatis(SqlMapClient arg) {
        setSqlMapClient(arg);
    }

    @Override
    public Long agregarMocion(Mocion mocion) throws DataAccessException {
        Map parameterMap = IbatisUtils.processBean(mocion);
        return ((Long)getSqlMapClientTemplate().queryForObject("agregarMocion", parameterMap)).longValue();
    }

    @Override
    public Integer modificarMocion(Mocion mocion) throws DataAccessException {
        Map parameterMap = IbatisUtils.processBean(mocion);
        return ((Integer)getSqlMapClientTemplate().update("modificarMocion", parameterMap));
    }

    @Override
    public Integer eliminarMocion(Long codigo) throws DataAccessException {
        Mocion mocion = new Mocion();
        mocion.setCodigo(codigo);
        return ((Integer)getSqlMapClientTemplate().delete("eliminarMocion", mocion));
    }

    @Override
    public List<Mocion> listarMocion(Mocion mocion) throws DataAccessException {
        Map parameterMap = IbatisUtils.processBean(mocion);
        return getSqlMapClientTemplate().queryForList("listarMocion", parameterMap);
    }
}
